package com.guiji.quartz.task;

import cn.hutool.core.util.ClassUtil;
import cn.hutool.extra.spring.SpringUtil;
import org.quartz.simpl.SimpleThreadPool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.lang.reflect.Field;
import java.util.LinkedList;
import java.util.List;

/**
 * @program: cms-vue-plus
 * @description:
 * @author: gaoX
 * @create: 2021-09-07 11:18
 **/
@Component("printLogsTask")
public class PrintLogsTask {
	private static final Logger log = LoggerFactory.getLogger(PrintLogsTask.class);

	public void printLogsTask() throws Exception {

		Object simpleThreadPool = SpringUtil.getApplicationContext();

		Field availWorkers = ClassUtil.getDeclaredField(SimpleThreadPool.class, "availWorkers");
		LinkedList ls = new LinkedList<>();
		List list = (List) availWorkers.get(ls);
		list.size();
//		log.info(availWorkers.get);
//
//
//		log.info("{}, {},taskCount [{}], completedTaskCount [{}], activeCount [{}], queueSize [{}]",
//			this.getThreadNamePrefix(),
//			prefix,
//			threadPoolExecutor.getTaskCount(),
//			threadPoolExecutor.getCompletedTaskCount(),
//			threadPoolExecutor.getActiveCount(),
//			threadPoolExecutor.getQueue().size());
	}

}
